<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('招聘需求申请列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addRecruit()" shiro:hasPermission="hr:recruitNeed:add">
                    <i class="fa fa-plus"></i> 招聘需求申请
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('hr:recruitNeed:edit')}]];

        var recruitDeptAllDatas = [[${@deptService.getDeptAll()}]];
        var recruitPostAllDatas = [[${@postService.getPostAll()}]];

        var prefix = ctx + "hr/recruitNeed";
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                detailUrl: prefix + "/detail/{id}",
                exportUrl: prefix + "/export",
                modalName: "招聘需求申请",
                uniqueId: "recruitNeedId",
                columns: [
                    {
                        title: '序号',
                        formatter: function (value, row, index) {
                            return index+1;
                        }
                    },
                    {
                        field: 'recruitPostId',
                        title: '招聘岗位',
                        formatter: function(value, row, index) {
                           return $.table.selectPostLabel(recruitPostAllDatas, value);
                        }

                    },
                    {
                        field: 'recruitCount',
                        title: '招聘人数'
                    },
                    {
                        field: 'empName',
                        title: '申请人'
                    }, {
                        field: 'todoUserName',
                        title: '当前处理人'
                    },{
                        field: 'auditStatus',
                        title: '审核状态',
                        formatter: function(value, row, index) {
                            //0：待审核，1：审核中，2：通过，3：未通过
                            if (value == 0){
                                return '待提交';
                            }
                            if (value == 1){
                                return '审核中';
                            }
                            if (value == 2){
                                return '通过';
                            }
                            if (value == 4){
                                return '撤销';
                            }
                            return '拒绝';
                        }
                    },
                    {
                        field: 'recruitDeptId',
                        title: '申请部门',
                        formatter: function(value, row, index) {
                            return $.table.selectDeptLabel(recruitDeptAllDatas, value);
                        }
                    },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.recruitNeedId + '\')"><i class="fa fa-edit"></i>详情</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.showHistoryDialog(\'' + row.instanceId + '\')"><i class="fa fa-list"></i> 审批历史</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.showProcessImgDialog(\'' + row.instanceId + '\')"><i class="fa fa-image"></i> 进度查看</a> ');
                        /*if (row.releaseStatus == 0){
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="submitRecruit(\'' + row.recruitNeedId + '\')"><i class="fa fa-remove"></i>提交</a> ');
                        }*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function submitRecruit(recruitNeedId) {
            $.operate.post(prefix + "/submitRecruit", {"recruitNeedId":recruitNeedId},function (result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.alertSuccess(result.msg)
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
            });
        }
        
        function addRecruit() {
            openDiv("招聘需求申请" ,  prefix + "/add",1300);
        }

        function openDiv(title, url, width, height, callback) {
            //如果是移动端，就使用自适应大小弹窗
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }
            if ($.common.isEmpty(title)) {
                title = false;
            }
            if ($.common.isEmpty(url)) {
                url = "/404.html";
            }
            if ($.common.isEmpty(width)) {
                width = 800;
            }
            if ($.common.isEmpty(height)) {
                height = ($(window).height() - 50);
            }

            layer.open({
                type: 2,
                area: [width + 'px', height + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: title,
                content: url,
                btn: ['提交', '关闭'],
                btnclass: ['btn btn-primary','fa fa-edit','fa fa-remove'],
                // 弹层外区域关闭
                shadeClose: false,
                success: function(layero, index){
                },
                /*yes: function (index, layero) {
                    // debugger
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },*/
                yes: function (index, layero) {
                    // debugger
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandlerPush(index, layero);
                    return false //开启该代码可禁止点击该按钮关闭
                },
                cancel: function (index) {
                    // debugger
                    return true;
                }
            });
        }

        
    </script>
</body>
</html>